package form;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

import com.mysql.jdbc.PreparedStatement;

public class ConnectionDB {
	static Connection connection;

	public static Connection getConnection() throws ClassNotFoundException,
			SQLException {
		if ((connection == null) || (connection.isClosed())) {
			Class.forName("com.mysql.jdbc.Driver");
			connection = DriverManager
					.getConnection(
							"jdbc:mysql://localhost:3306/"+"tincongnghe?useUnicode=true&characterEncoding=utf-8",
							"root", "");
			return connection;
		} else {
			return connection;
		}

	}
}
